home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Applications / QuArK / plugins / mapquake2entitylines.py < prev    next >
Text File  |  2004-01-05  |  3KB  |  80 lines

  1. """   QuArK  -  Quake Army Knife
  2. """
  3. #
  4. # Copyright (C) 1996-99 Armin Rigo
  5. # THIS FILE IS PROTECTED BY THE GNU GENERAL PUBLIC LICENCE
  6. # FOUND IN FILE "COPYING.TXT"
  7. #
  8.  
  9. #$Header: /cvsroot/quark/runtime/plugins/mapquake2entitylines.py,v 1.1 2001/01/06 18:34:22 decker_dk Exp $
  10.  
  11. Info = {
  12.    "plug-in":       "Quake-2 Arrow Extensions",
  13.    "desc":          "Displays axis for rotating entities",
  14.    "date":          "15 jan 99",
  15.    "author":        "Decker",
  16.    "author e-mail": "decker@post1.tele.dk",
  17.    "quark":         "Version 5.4" }
  18.  
  19.  
  20. from quarkpy.maputils import *
  21. import quarkpy.mapentities
  22. from quarkpy.qeditor import MapColor
  23.  
  24. DefaultDrawEntityLines = quarkpy.mapentities.DefaultDrawEntityLines
  25. ObjectOrigin = quarkpy.mapentities.ObjectOrigin
  26.  
  27. import plugins.deckerutils
  28. FindOriginFlagPolyPos = plugins.deckerutils.FindOriginFlagPolyPos
  29.  
  30. class Quake2DrawEntityLines(DefaultDrawEntityLines):
  31.  
  32.    def showoriginline(self, entity, xaxisbitvalue, yaxisbitvalue, view, color):
  33.         orgpos = FindOriginFlagPolyPos(entity)
  34.         if orgpos is not None:
  35.             try:
  36.                 axisflags = int(entity["spawnflags"])
  37.             except:
  38.                 axisflags = 0
  39.             axisdist = quarkx.vect(0, 0, 0)
  40.             if axisflags & xaxisbitvalue:
  41.                 axisdist = quarkx.vect(16, 0, 0) # 16 is just some appropriate value I choosed
  42.             elif axisflags & yaxisbitvalue:
  43.                 axisdist = quarkx.vect(0, 16, 0)
  44.             else:
  45.                 axisdist = quarkx.vect(0, 0, 16)
  46.             cv = view.canvas()
  47.             cv.pencolor = color
  48.             cv.penwidth = 3 # So it the axis gets more visual
  49.             pos1, pos2 = (orgpos + axisdist), (orgpos - axisdist)
  50.             vpos1, vpos2 = view.proj(pos1), view.proj(pos2)
  51.             cv.line(vpos1, vpos2)
  52.  
  53.    def drawentitylines(self, entity, org, view, entities, processentities):
  54.         # Draw the default target/targetname/killtarget/light/_light arrows/ellipse
  55.         DefaultDrawEntityLines.drawentitylines(self, entity, org, view, entities, processentities)
  56.         # From here its Quake-2 special
  57.         axiscolor = MapColor("Axis")
  58.         rotcolor = 0xff00ff     # (magenta) rotation axis
  59.         org1 = view.proj(org)
  60.         if org1.visible:
  61.             if entity.name == "func_rotating:b":
  62.                 self.showoriginline(entity, 4, 8, view, rotcolor) # func_rotating has different bitvalues for X-axis and Y-axis
  63.             elif entity.name == "func_door_rotating:b":
  64.                 self.showoriginline(entity, 64, 128, view, rotcolor)
  65.  
  66. #
  67. # Register this class with its gamename
  68. #
  69. quarkpy.mapentities.EntityLinesMapping.update({
  70.   "Quake 2": Quake2DrawEntityLines()
  71. })
  72.  
  73. # ----------- REVISION HISTORY ------------
  74. #
  75. # $Log: mapquake2entitylines.py,v $
  76. # Revision 1.1  2001/01/06 18:34:22  decker_dk
  77. # Was in quark 5.10
  78. #
  79. #
  80.